You need to enable the scene depth semantics first.
let config = ARWorldTrackingConfiguration()
config.frameSemantics = [.sceneDepth, .smoothedSceneDepth]
arSession.run(config)
Topic:
App & System Services
SubTopic:
Core OS
Tags: